package leetcode_day._2022._202201._1120;

/**
 * @author yzh
 * @version 1.0
 * @date 2022/1/15 22:56
 * 计算力扣银行的钱
 * 算法：模拟
 */
public class _15_1716 {

    public int totalMoney(int n) {
        int ans = 0, a = n / 7, b = n % 7;
        if (a >= 1) {
            int an = 28 + (a - 1) * 7;
            ans += a * (28 + an) / 2;
        }
        ans += (a + 1 + a + b) * b / 2;
        return ans;
    }

}
